package com.ybwh.springboot2.conf;

import com.github.pagehelper.PageInterceptor;
import com.ybwh.springboot2.common.mybatis.plugin.sass.tenantid.TenantIdColumIntercepter;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;


@Configuration
@MapperScan("com.ybwh.*.dao*")
public class MybatisConfig {

    @Value("${mybatis.table-router.ignore-tables}")
    private String ignoreTables;

    /**
     * 分页插件
     */
    @Bean
    public PageInterceptor pageInterceptor() {
        PageInterceptor pageInterceptor0 = new PageInterceptor();
        Properties properties = new Properties();
        properties.put("helperDialect", "mysql");
        //参数方法调用
        properties.put("supportMethodsArguments", "true");

        pageInterceptor0.setProperties(properties);
        return pageInterceptor0;
    }


//	@Bean
//	public SassSchemaInterceptor sassSchemaInterceptor(){
//		return new SassSchemaInterceptor(ignoreTables);
//	}


    @Bean
    public TenantIdColumIntercepter tenantIdColumIntercepter() {
        return new TenantIdColumIntercepter(ignoreTables, "tenant_id");
    }


}